<?php

Raise::load('core.datetime.RaiseTime');

class TestCoreRaiseTime extends RaiseTest {
    
    function testClass(){
        self::assertClassExists('RaiseTime');
    }
    
    function testCreate(){
        $time = new RaiseTime(6, 2, 3);
        self::assertStrictEqual($time->hour(), 6);
        self::assertStrictEqual($time->minute(), 2);
        self::assertStrictEqual($time->second(), 3);
    }
    
    function testChangeTime(){
        $time = new RaiseTime(6, 2, 3);
        $time->minute($time->minute() + 63);
        self::assertStrictEqual($time->hour(), 7);
        self::assertStrictEqual($time->minute(), 5);
        self::assertStrictEqual($time->second(), 3);
    }
    
    function testChangeTime2(){
        $time = new RaiseTime(6, 59, 30);
        $time->second($time->second() + 33);
        self::assertStrictEqual($time->hour(), 7);
        self::assertStrictEqual($time->minute(), 0);
        self::assertStrictEqual($time->second(), 3);
    }
    
    function testChangeTime3(){
        $time = new RaiseTime(6, 59, 30);
        $time->second($time->second() + 243);
        self::assertStrictEqual($time->hour(), 7);
        self::assertStrictEqual($time->minute(), 3);
        self::assertStrictEqual($time->second(), 33);
    }
    
    function testAdd(){
        $time1 = new RaiseTime(23, 1, 5);
        $time2 = new RaiseTime(1, 5, 20);
        $time3 = $time1->add($time2);
        self::assertObjectClass($time3, 'RaiseTime');
        self::assertStrictEqual($time3->hour(), 0);
        self::assertStrictEqual($time3->minute(), 6);
        self::assertStrictEqual($time3->second(), 25);
    }
    
    function testAdd2(){
        $time1 = new RaiseTime(23, 1, 5);
        $time2 = new RaiseTime(1, 85, 80); // -> 2 26 20
        $time3 = $time1->add($time2);
        self::assertObjectClass($time3, 'RaiseTime');
        self::assertStrictEqual($time3->hour(), 1);
        self::assertStrictEqual($time3->minute(), 27);
        self::assertStrictEqual($time3->second(), 25);
    }
    
    function testSubtract(){
        $time1 = new RaiseTime(23, 6, 5);
        $time2 = new RaiseTime(1, 5, 20);
        $time3 = $time1->subtract($time2);
        self::assertObjectClass($time3, 'RaiseTime');
        self::assertStrictEqual($time3->hour(), 22);
        self::assertStrictEqual($time3->minute(), 0);
        self::assertStrictEqual($time3->second(), 45);
    }
    
    function testSubtract2(){
        $time1 = new RaiseTime(15, 6, 5);
        $time2 = new RaiseTime(1, 65, 20);
        $time3 = $time1->subtract($time2);
        self::assertObjectClass($time3, 'RaiseTime');
        self::assertStrictEqual($time3->hour(), 13);
        self::assertStrictEqual($time3->minute(), 0);
        self::assertStrictEqual($time3->second(), 45);
    }
    
}
